<?php

namespace app\api\controller;

use app\admin\model\shop\Article;
use app\admin\model\shop\Likelog;
use app\admin\model\shop\Order;
use app\admin\model\shop\Shoplist;
use app\common\controller\Api;
use think\Config;

/**
 * 订单接口
 */
class OrderList extends Api
{
    // 无需登录的接口,*表示全部
    protected $noNeedLogin = [];//['test', 'test1'];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];//['test2'];
    /**
     * 我的订单
     * @ApiParams   (name="type", type="int", sample="状态:0=未支付,1=成功,2=过期,3=退款", required=false, description="type")
     * @ApiParams   (name="page", type="int", sample="page", description="page")
     * @ApiParams   (name="limit", type="int", sample="limit", description="limit")
     * @ApiParams   (name="order_id", type="int", sample="order_id", required=false, description="订单ID")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturnParams   (name="data", type="object", sample="", description="")
     */
    public function orderList(){
        $page = $this->request->request('page');
        $limit = $this->request->request('limit');
        $type = $this->request->param('type','');
        $order_id = $this->request->param('order_id',0);
        $token = $this->auth->getUserinfo();
        $where=[];
        if ($order_id){
            $where['id'] = $order_id;
        }
        $where['user_id'] = $token['user_id'];
        if (is_null($type)){
            $where['status'] = $type;
        }
        $order = Order::with('shop')->where($where)->page($page,$limit)->select();
        return $this->success('',$order);
    }



}
